package com.leyou.sh.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.sh.item.dto.SpecParamDTO;
import com.leyou.sh.item.entity.SpecParam;
import com.leyou.sh.item.mapper.SpecParamMapper;
import com.leyou.sh.item.service.SpecParamService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author balisong_fcs
 * @date 2020/12/28 20:20
 * @desc 规格参数的service
 */
@Service
public class SpecParamServiceImpl extends ServiceImpl<SpecParamMapper, SpecParam> implements SpecParamService {

    @Override
    public List<SpecParamDTO> querySpecParamByCidAndGid(Long categoryId,Long groupId,Boolean searching) {
        return SpecParamDTO.convertEntityList(this.query()
                .eq(null != categoryId, "category_id", categoryId)
                .eq(null != groupId, "group_id", groupId)
                .eq(null != searching, "searching", searching)
                .list());
    }

    @Override
    public void addParam(SpecParamDTO specParamDTO) {
        this.save(specParamDTO.toEntity(SpecParam.class));
    }

    @Override
    public void updateParm(SpecParamDTO specParamDTO) {
        this.updateById(specParamDTO.toEntity(SpecParam.class));
    }
}
